s = input().split()

L = int(s[0])
M = int(s[1])

good = [True] * (L+1)

for i in range(M):
    s = input().split()
    start = int(s[0])
    end = int(s[1])
    for k in range(start, end + 1):
        good[k] = False
print(sum(good))